<?php


namespace app\admin\model;


use think\Model;

class ClassQu extends Model
{
    protected $autoWriteTimestamp = true;
    public static function list()
    {
        $sql = ClassQu::field("*");


        $c = $sql->count();
        $l = $sql->select();

        return listDate($l,$c);
    }

    public static function add($title,$staffNo)
    {
        $qu = ClassQu::field("id")->where("title",$title)->find();
        if($qu){
            return "数据已存在~";
        }
        ClassQu::create(["title"=>$title,"staff_no"=>$staffNo]);
        return "";
    }

    public static function up($title,$id,$staffNo)
    {
        $qu = ClassQu::field("id")->where("id",$id)->find();
        if(!$qu){
            return "数据不存在~";
        }
        ClassQu::where("id",$id)->data(["title"=>$title,"staff_no"=>$staffNo])->update();
        return "";
    }

    public static function del($id)
    {
        $qu = ClassQu::field("id")->where("id",$id)->find();
        if(!$qu){
            return "数据不存在~";
        }
        ClassQu::where("id",$id)->delete();
        return "";
    }
}